#include <iostream>
#include <ctime>
#include <string>
#include <sstream>
#include "uptime.h"

static std::string version = "v0.0.2-cpp";

std::string get_time() {
    std::time_t t = std::time(nullptr);
    std::tm tm = *std::localtime(&t);
    std::stringstream time_ss;
    time_ss << (tm.tm_hour % 12 == 0 ? 12 : tm.tm_hour % 12) << ':'
            << (tm.tm_min < 10 ? "0" : "") << tm.tm_min << ' '
            << (tm.tm_hour >= 12 ? "PM" : "AM") << " - "
            << std::string(tm.tm_wday == 0 ? "Sun" : tm.tm_wday == 1 ? "Mon" : tm.tm_wday == 2 ? "Tue" : tm.tm_wday == 3 ? "Wed" : tm.tm_wday == 4 ? "Thu" : tm.tm_wday == 5 ? "Fri" : "Sat")
            << ' ' << (tm.tm_mon < 9 ? "0" : "") << tm.tm_mon + 1 << '/'
            << (tm.tm_mday < 10 ? "0" : "") << tm.tm_mday << '/'
            << (tm.tm_year - 100 < 10 ? "0" : "") << tm.tm_year - 100;
    return time_ss.str();
}

int print_separation () {
    std::cout << "==================================================" << std::endl;
    return 0;
}

int print_header () {
    print_separation();
    std::cout << "Betsu Banner " << version << " : " << get_time() << std::endl;
    print_separation();
    return 0;
}


int main (void) {
    print_header();
    std::cout << " - up ";
    print_uptime();
    return 0;
}
